package com.shanghaionstar.user.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.onstar.cn.sqlite.entities.BroadcastHeaderEntity;
import com.onstar.cn.framework.annotation.FindViewById;
import com.onstar.cn.framework.base.CommonViewHolder;
import com.shanghaionstar.R;

import java.util.List;

public class BroadCastListAdapter extends com.onstar.cn.framework.base.CommonAdapter<BroadcastHeaderEntity>{
   Context mContext;
   private List<BroadcastHeaderEntity> allbroadcast;

	/** 
	* @Description: TODO
	* @author Mengting Lu
	* @date 2015年8月7日 上午9:25:39 
	*/
	public BroadCastListAdapter(List<BroadcastHeaderEntity> allbroadcasts, Context context) {
		super(allbroadcasts, context);
		mContext = context;
		allbroadcast = allbroadcasts;
	}

	/**
	* (non-Javadoc) 
	* <p>Title: getView</p> 
	* <p>Description: </p> 
	* @param position
	* @param viewHolder 
	* @see com.onstar.cn.framework.base.CommonAdapter#getView(int, com.onstar.cn.framework.base.CommonViewHolder) 
	*/
	@Override
	public void getView(int position, CommonViewHolder viewHolder) {
		ViewHolder holder = (ViewHolder)viewHolder;
		BroadcastHeaderEntity broadinfo = allbroadcast.get(position);
		if (broadinfo.getIsRead().equals("true")) {
			holder.iv_unread.setVisibility(View.INVISIBLE);
		} else {
			holder.iv_unread.setVisibility(View.VISIBLE);
		}
		holder.broadcast_title.setText(broadinfo.getTitle());
		holder.tv_messageid.setText(broadinfo.getBroadcastId()+"");
		
	}

	/**
	* (non-Javadoc) 
	* <p>Title: layoutId</p> 
	* <p>Description: </p> 
	* @return 
	* @see com.onstar.cn.framework.base.CommonAdapter#layoutId() 
	*/
	@Override
	public int layoutId() {
		return R.layout.onstar_broadcast_list_item;
	}

	/**
	* (non-Javadoc) 
	* <p>Title: getViewHolder</p> 
	* <p>Description: </p> 
	* @return 
	* @see com.onstar.cn.framework.base.CommonAdapter#getViewHolder() 
	*/
	@Override
	public CommonViewHolder getViewHolder() {
		return new ViewHolder();
	}
	
	private class ViewHolder extends CommonViewHolder{
		@FindViewById
		private ImageView iv_unread;
		@FindViewById
		private TextView broadcast_title,tv_messageid;
	}

}